package com.google.code.jgchart;

public class GridLine implements UrlQuery {

	private static final String GRID_LINE_PARAM = "chg=";

	public int xAsisSetpSize;

	public int yAsisSetpSize;

	public Integer lengthOfLineSegment;

	public Integer lengthOfBlankSegment;

	public GridLine(int xAsisSetpSize, int yAsisSetpSize) {
		this.xAsisSetpSize = xAsisSetpSize;
		this.yAsisSetpSize = yAsisSetpSize;
	}

	public GridLine(int xAsisSetpSize, int yAsisSetpSize,
			int lengthOfLineSegment, int lengthOfBlankSegment) {
		this.xAsisSetpSize = xAsisSetpSize;
		this.yAsisSetpSize = yAsisSetpSize;
		setLengthOfLineSegment(lengthOfLineSegment);
		setLengthOfBlankSegment(lengthOfBlankSegment);
	}

	public GridLine setLengthOfLineSegment(int length) {
		this.lengthOfLineSegment = length;
		return this;
	}

	public GridLine setLengthOfBlankSegment(int length) {
		this.lengthOfBlankSegment = length;
		return this;
	}

	public String[] getQuery() {
		StringBuilder sb = new StringBuilder();
		String split = ",";
		sb.append(GRID_LINE_PARAM).append(xAsisSetpSize).append(split).append(
				yAsisSetpSize);
		if (lengthOfLineSegment != null) {
			sb.append(split).append(lengthOfLineSegment);
		}
		if (lengthOfBlankSegment != null) {
			sb.append(split).append(lengthOfBlankSegment);
		}

		return new String[] { sb.toString() };
	}
}
